using DevExpress.Utils;
using System;
using System.Globalization;
using System.Windows.Forms;
namespace Common.Class
{
	public class ClsOption
	{
		public class Regional
		{
			private static bool _mIsQuestion = true;
			private static string _mDecimalSymbol = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
			private static bool _mIsMsgBoxResult = true;
			private static string _mDigitGroupSymbol = CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator;
			private static int _mDecimals = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalDigits;
			private static string _mDateSaparator = CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator;
			private static string _mFormatDate = "dd/MM/yyyy";
			private static ClsOption.FormatType _mDateFormatType = ClsOption.FormatType.Custom;
			private static string _mFormatNumber = "##,##0.###";
			public static string FormatNumber
			{
				get
				{
					string text = "##,##0.";
					for (int i = 0; i < ClsOption.Regional._mDecimals; i++)
					{
						text += "#";
					}
					ClsOption.Regional._mFormatNumber = text;
					return text;
				}
				set
				{
					ClsOption.Regional._mFormatNumber = value;
				}
			}
			public static string StringFormat
			{
				get
				{
					return "{0:" + ClsOption.Regional.FormatNumber + "}";
				}
			}
			public static ClsOption.FormatType DateFormatType
			{
				get
				{
					return ClsOption.Regional._mDateFormatType;
				}
				set
				{
					ClsOption.Regional._mDateFormatType = value;
				}
			}
			public static string FormatDate
			{
				get
				{
					string mFormatDate;
					switch (ClsOption.Regional._mDateFormatType)
					{
					case ClsOption.FormatType.Dmy:
						ClsOption.Regional._mFormatDate = ClsOption.FormatType.Dmy.ToString().Replace("/", ClsOption.Regional._mDateSaparator);
						mFormatDate = ClsOption.Regional._mFormatDate;
						break;
					case ClsOption.FormatType.Mdy:
						ClsOption.Regional._mFormatDate = ClsOption.FormatType.Mdy.ToString().Replace("/", ClsOption.Regional._mDateSaparator);
						mFormatDate = ClsOption.Regional._mFormatDate;
						break;
					case ClsOption.FormatType.Ymd:
						ClsOption.Regional._mFormatDate = ClsOption.FormatType.Ymd.ToString().Replace("/", ClsOption.Regional._mDateSaparator);
						mFormatDate = ClsOption.Regional._mFormatDate;
						break;
					default:
						mFormatDate = ClsOption.Regional._mFormatDate;
						break;
					}
					return mFormatDate;
				}
				set
				{
					ClsOption.Regional._mDateFormatType = ClsOption.FormatType.Custom;
					ClsOption.Regional._mFormatDate = value;
				}
			}
			public static string DateSaparator
			{
				get
				{
					return ClsOption.Regional._mDateSaparator;
				}
				set
				{
					ClsOption.Regional._mDateSaparator = value;
				}
			}
			public static int Decimals
			{
				get
				{
					return ClsOption.Regional._mDecimals;
				}
				set
				{
					ClsOption.Regional._mDecimals = value;
				}
			}
			public static string DigitGroupSymbol
			{
				get
				{
					return ClsOption.Regional._mDigitGroupSymbol;
				}
				set
				{
					ClsOption.Regional._mDigitGroupSymbol = value;
				}
			}
			public static string DecimalSymbol
			{
				get
				{
					return ClsOption.Regional._mDecimalSymbol;
				}
				set
				{
					ClsOption.Regional._mDecimalSymbol = value;
				}
			}
			public static bool IsQuestion
			{
				get
				{
					return ClsOption.Regional._mIsQuestion;
				}
				set
				{
					ClsOption.Regional._mIsQuestion = value;
				}
			}
			public static bool IsMsgBoxResult
			{
				get
				{
					return ClsOption.Regional._mIsMsgBoxResult;
				}
				set
				{
					ClsOption.Regional._mIsMsgBoxResult = value;
				}
			}
		}
		public enum FormatType
		{
			Dmy = 1,
			Mdy,
			Ymd,
			Custom = 0
		}
		public class Number
		{
			private static string _mDecimalSymbol = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
			private static string _mDigitGroupSymbol = CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator;
			private static int _mDecimals = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalDigits;
			private static string _mFrefixSymbol = "";
			private static string _mSuffixSymbol = "";
			private static string _mFormatNumber = "##,##0.###";
			private static string Format
			{
				get
				{
					string text = "##,##0.";
					for (int i = 0; i < ClsOption.Number._mDecimals; i++)
					{
						text += "#";
					}
					ClsOption.Number._mFormatNumber = ClsOption.Number._mFrefixSymbol + text + ClsOption.Number._mSuffixSymbol;
					return ClsOption.Number._mFormatNumber;
				}
				set
				{
					ClsOption.Number._mFormatNumber = value;
				}
			}
			public static string FormatString
			{
				get
				{
					return "{0:" + ClsOption.Number.Format + "}";
				}
			}
			public static string PercentFormatString
			{
				get
				{
					return "{0:" + ClsOption.Number.Format + "} %";
				}
			}
			public static int Decimals
			{
				get
				{
					return ClsOption.Number._mDecimals;
				}
				set
				{
					ClsOption.Number._mDecimals = value;
				}
			}
			public static string DigitGroupSymbol
			{
				get
				{
					return ClsOption.Number._mDigitGroupSymbol;
				}
				set
				{
					ClsOption.Number._mDigitGroupSymbol = value;
				}
			}
			public static string DecimalSymbol
			{
				get
				{
					return ClsOption.Number._mDecimalSymbol;
				}
				set
				{
					ClsOption.Number._mDecimalSymbol = value;
				}
			}
			public static string FrefixSymbol
			{
				get
				{
					return ClsOption.Number._mFrefixSymbol;
				}
				set
				{
					ClsOption.Number._mFrefixSymbol = value;
				}
			}
			public static string SuffixSymbol
			{
				get
				{
					return ClsOption.Number._mSuffixSymbol;
				}
				set
				{
					ClsOption.Number._mSuffixSymbol = value;
				}
			}
		}
		public class DateTime
		{
			private static string _mDateSaparator = CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator;
			private static string _mFormatDate = "dd/MM/yyyy";
			private static int _mDayLength = 2;
			private static int _mMonthLength = 2;
			private static int _mYearLength = 4;
			private static ClsOption.FormatType _mDateFormatType = ClsOption.FormatType.Custom;
			public static ClsOption.FormatType FormatType
			{
				get
				{
					return ClsOption.DateTime._mDateFormatType;
				}
				set
				{
					ClsOption.DateTime._mDateFormatType = value;
				}
			}
			public static string Format
			{
				get
				{
					string mFormatDate;
					switch (ClsOption.DateTime._mDateFormatType)
					{
					case ClsOption.FormatType.Dmy:
					{
						string day = ClsOption.DateTime.GetDay(true);
						string month = ClsOption.DateTime.GetMonth(true);
						string year = ClsOption.DateTime.GetYear(false);
						ClsOption.DateTime._mFormatDate = ((day.Length == 1) ? "" : (day + ((month.Length == 1) ? "" : month) + year));
						if (ClsOption.DateTime._mFormatDate.Trim() == string.Empty)
						{
							ClsOption.DateTime._mFormatDate = "dd/MM/yyyy";
						}
						mFormatDate = ClsOption.DateTime._mFormatDate;
						break;
					}
					case ClsOption.FormatType.Mdy:
					{
						string day = ClsOption.DateTime.GetDay(true);
						string month = ClsOption.DateTime.GetMonth(true);
						string year = ClsOption.DateTime.GetYear(false);
						ClsOption.DateTime._mFormatDate = ((month.Length == 1) ? "" : (month + ((day.Length == 1) ? "" : day) + year));
						if (ClsOption.DateTime._mFormatDate.Trim() == string.Empty)
						{
							ClsOption.DateTime._mFormatDate = "MM/dd/yyyy";
						}
						mFormatDate = ClsOption.DateTime._mFormatDate;
						break;
					}
					case ClsOption.FormatType.Ymd:
					{
						string day = ClsOption.DateTime.GetDay(false);
						string month = ClsOption.DateTime.GetMonth(true);
						string year = ClsOption.DateTime.GetYear(true);
						ClsOption.DateTime._mFormatDate = ((year.Length == 1) ? "" : (year + ((month.Length == 1) ? "" : month) + day));
						if (ClsOption.DateTime._mFormatDate.Trim() == string.Empty)
						{
							ClsOption.DateTime._mFormatDate = "yyyy/MM/dd";
						}
						mFormatDate = ClsOption.DateTime._mFormatDate;
						break;
					}
					default:
						mFormatDate = ClsOption.DateTime._mFormatDate;
						break;
					}
					return mFormatDate;
				}
				set
				{
					ClsOption.DateTime._mDateFormatType = ClsOption.FormatType.Custom;
					ClsOption.DateTime._mFormatDate = value;
				}
			}
			public static string FormatString
			{
				get
				{
					return "{0:" + ClsOption.DateTime.Format + "}";
				}
			}
			public static string Saparator
			{
				get
				{
					return ClsOption.DateTime._mDateSaparator;
				}
				set
				{
					ClsOption.DateTime._mDateSaparator = value;
				}
			}
			public static int DayLength
			{
				get
				{
					return ClsOption.DateTime._mDayLength;
				}
				set
				{
					ClsOption.DateTime._mDayLength = value;
				}
			}
			public static int MonthLength
			{
				get
				{
					return ClsOption.DateTime._mMonthLength;
				}
				set
				{
					ClsOption.DateTime._mMonthLength = value;
				}
			}
			public static int YearLength
			{
				get
				{
					return ClsOption.DateTime._mYearLength;
				}
				set
				{
					ClsOption.DateTime._mYearLength = value;
				}
			}
			private static string GetDay(bool dateSaparator)
			{
				string text = "";
				for (int i = 0; i < ClsOption.DateTime._mDayLength; i++)
				{
					text += "d";
				}
				if (dateSaparator)
				{
					text += ClsOption.DateTime._mDateSaparator;
				}
				return text;
			}
			private static string GetMonth(bool dateSaparator)
			{
				string text = "";
				for (int i = 0; i < ClsOption.DateTime._mMonthLength; i++)
				{
					text += "M";
				}
				if (dateSaparator)
				{
					text += ClsOption.DateTime._mDateSaparator;
				}
				return text;
			}
			private static string GetYear(bool dateSaparator)
			{
				string text = "";
				for (int i = 0; i < ClsOption.DateTime._mYearLength; i++)
				{
					text += "y";
				}
				if (dateSaparator)
				{
					text += ClsOption.DateTime._mDateSaparator;
				}
				return text;
			}
		}
		public class System2
		{
			private static bool _mIsQuestion = true;
			public static bool IsQuestion
			{
				get
				{
					return ClsOption.System2._mIsQuestion;
				}
				set
				{
					ClsOption.System2._mIsQuestion = value;
				}
			}
		}
		private static WaitDialogForm _dlg;
		public static void CreateWaitDialog()
		{
			if (ClsOption._dlg == null)
			{
				ClsOption._dlg = new WaitDialogForm("Đang nạp dữ liệu ...", "Vui lòng đợi trong giây lát...");
			}
		}
		public static void SetWaitDialogCaption(string fCaption)
		{
			if (ClsOption._dlg != null)
			{
				ClsOption._dlg.Caption = fCaption;
			}
			else
			{
				ClsOption._dlg = new WaitDialogForm(fCaption, "Vui lòng đợi trong giây lát...");
			}
		}
		public static void DoHide()
		{
			if (ClsOption._dlg != null)
			{
				ClsOption._dlg.FormClosing += new FormClosingEventHandler(ClsOption.dlg_FormClosing);
				ClsOption._dlg.Close();
			}
		}
		private static void dlg_FormClosing(object sender, FormClosingEventArgs e)
		{
			ClsOption._dlg = null;
		}
		~ClsOption()
		{
			if (ClsOption._dlg != null)
			{
				ClsOption._dlg.FormClosing += new FormClosingEventHandler(ClsOption.dlg_FormClosing);
				ClsOption._dlg.Close();
			}
		}
	}
}
